package com.qianya.system.manage.web.sys.controller;

import com.qianya.system.manage.web.sys.model.SysSetLimitIp;
import com.qianya.system.manage.web.sys.service.ISysSetLimitIpService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;

import org.springframework.web.bind.annotation.*;
import org.springframework.beans.BeanUtils;
import com.qianya.model.common.CommonResult;
import com.qianya.model.pojo.sys.qo.SysSetLimitIpQO;

import javax.servlet.http.HttpServletRequest;
    import org.springframework.web.bind.annotation.RestController;
/**
* <p>
    * 前台ip访问限制 前端控制器
    * </p>
*
* @author lhl
* @since 2020-06-11
*/
    @RestController
@RequestMapping("/sys/sys-set-front-ip")
@Api(value = "SysSetFrontIpController", tags = "前台ip访问限制接口")
@Slf4j
public class SysSetLimitIpController {

    private Logger logger = LoggerFactory.getLogger(SysSetLimitIpController.class);

    @Autowired
    private ISysSetLimitIpService sysSetFrontIpService;

    @PutMapping(value = "/update")
    @ApiOperation("修改前台ip访问限制")
    public CommonResult update(@RequestBody SysSetLimitIpQO sysSetLimitIpQO, HttpServletRequest request){

        SysSetLimitIp sysSetFrontIp = new SysSetLimitIp();

        BeanUtils.copyProperties(sysSetLimitIpQO,sysSetFrontIp);

        return sysSetFrontIpService.renewal(sysSetFrontIp,request);
    }

    @ApiOperation("查找前台ip访问限制")
    @GetMapping(value = "/find")
    public CommonResult find(){
        return CommonResult.success(sysSetFrontIpService.list());
    }

    }
